package org.example;

import java.util.Scanner;

//Girlfriend
public class Exception_Demo2 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        Girlfriend gf=new Girlfriend();
        while (true) {
            try {
                System.out.println("请输入年龄:");
                String agestr = sc.nextLine();
                int age = Integer.parseInt(agestr);
                gf.setAge(age);
                System.out.println("请输入姓名：");
                String name = sc.nextLine();
                gf.setName(name);
                break;
            } catch (AgeOutOfBoundsException e) {
                e.printStackTrace();
            } catch (NameFormatException e) {
                e.printStackTrace();
            }catch (NumberFormatException e) {
                e.printStackTrace();
            }
            System.out.println(gf);
        }

    }
}
